package com.fudan.biz.visualize.service;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.fudan.biz.visualize.dao.ChartSettingDao;
import com.fudan.biz.visualize.entity.ChartSetting;
import com.fudan.framework.base.BaseDao;
import com.fudan.framework.base.DaoService;

@Service
public class ChartSettingService extends DaoService<ChartSetting> {

    @Autowired
    private ChartSettingDao chartSettingDao;

    @Override
    protected BaseDao<ChartSetting> injectDao() {
        return chartSettingDao;
    }

    public ChartSetting findByChartName(ChartSetting chartSetting) {
        return chartSettingDao.findByChartName(chartSetting.getChartName());
    }

    public Optional<ChartSetting> findByChartId(Integer chartId) {
        return chartSettingDao.findById(chartId);
    }
    @Transactional
    public Integer updateChartById(ChartSetting chartSetting) {
        return chartSettingDao.updateChartById(chartSetting.getId(), chartSetting.getChartName(),
                chartSetting.getChartDsId(), chartSetting.getChartDsName(), chartSetting.getChartMetrics(),
                chartSetting.getChartDimensions(), chartSetting.getChartQuerys(), chartSetting.getChartCustoms());
    }

}
